﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DataModel;
using BasicDataManagement;

namespace StaffManagement
{
    /// <summary>
    /// AddStaffWindow.xaml 的交互逻辑
    /// </summary>
    public partial class AddStaffWindow : Window
    {
        public StaffInfo staff { get; private set; }
        IOpertation op;

        public AddStaffWindow()
        {
            InitializeComponent();
            op = OperationFactory.Create();
            groupCB.ItemsSource = new ObservableCollection<AuthorityGroup>(op.LoadAuthorityGroups());
            staff = new StaffInfo();
        }

        private void BtnStaffInfoOK_Click(object sender, RoutedEventArgs e)
        {
            if (groupCB.Text.Equals("") || nameTB.Text.Equals("") || jobNumTB.Text.Equals("") || pwdTB.Text.Equals(""))
            {
                MessageBox.Show("请输入完整信息");
                return;
            }
            staff.GroupName = groupCB.Text;
            staff.Name = nameTB.Text;
            staff.JobNumber = jobNumTB.Text;
            staff.LoginPWD = pwdTB.Text;
            staff.Money = Convert.ToDecimal(moneyTB.Text);
            op.AddStaff(staff);
            this.DialogResult = true;
            this.Close();
        }

        private void BtnStaffInfoCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
    }
}
